fix(relay): never panic on multibyte request ids when naming worker threads - #27
Merged
Merged
Conversation
…hreads Thread names sliced the first 8 bytes of the cloud-controlled request id. A multibyte UTF-8 character in those bytes panics on a char boundary; release is panic = "abort", so one bad frame killed the relay. Truncate by characters instead. Closes #17 Co-authored-by: duyet <duyet@users.noreply.github.com>
Contributor
anyr size and startupStartup is wall time for a cold Size budget:
Budget check: ok raw timings[
{
"asset": "anyr-darwin-arm64",
"kind": "native",
"path": "/Users/runner/work/cli/cli/anyr-darwin-arm64",
"bytes": 2803480,
"size": "2.7 MiB",
"version": "0.1.11 (built 2026-08-28 04:29:16)",
"target": "aarch64-apple-darwin",
"os": "macos-latest",
"startup_version": {
"n": 21,
"min_ms": 2.62,
"median_ms": 2.88,
"p95_ms": 7.0,
"mean_ms": 3.93
},
"startup_help": {
"n": 21,
"min_ms": 2.29,
"median_ms": 2.51,
"p95_ms": 3.89,
"mean_ms": 3.02
}
},
{
"asset": "anyr-darwin-x86_64",
"kind": "native",
"path": "/Users/runner/work/cli/cli/anyr-darwin-x86_64",
"bytes": 3010560,
"size": "2.9 MiB",
"version": "0.1.11 (built 2026-08-28 04:29:32)",
"target": "x86_64-apple-darwin",
"os": "macos-latest",
"startup_version": {
"n": 21,
"min_ms": 28.3,
"median_ms": 35.89,
"p95_ms": 49.81,
"mean_ms": 36.59
},
"startup_help": {
"n": 21,
"min_ms": 27.06,
"median_ms": 33.77,
"p95_ms": 46.18,
"mean_ms": 34.47
}
},
{
"asset": "anyr-linux-arm64",
"kind": "native",
"path": "/home/runner/work/cli/cli/anyr-linux-arm64",
"bytes": 2757672,
"size": "2.6 MiB",
"version": "0.1.11 (built 2026-08-28 04:29:16)",
"target": "aarch64-unknown-linux-gnu",
"os": "ubuntu-24.04-arm",
"startup_version": {
"n": 21,
"min_ms": 0.66,
"median_ms": 0.7,
"p95_ms": 0.84,
"mean_ms": 0.72
},
"startup_help": {
"n": 21,
"min_ms": 0.7,
"median_ms": 0.76,
"p95_ms": 0.83,
"mean_ms": 0.76
}
},
{
"asset": "anyr-linux-x86_64",
"kind": "native",
"path": "/home/runner/work/cli/cli/anyr-linux-x86_64",
"bytes": 3110504,
"size": "3.0 MiB",
"version": "0.1.11 (built 2026-08-28 04:29:20)",
"target": "x86_64-unknown-linux-gnu",
"os": "ubuntu-latest",
"startup_version": {
"n": 21,
"min_ms": 0.94,
"median_ms": 0.95,
"p95_ms": 1.0,
"mean_ms": 0.96
},
"startup_help": {
"n": 21,
"min_ms": 0.91,
"median_ms": 0.94,
"p95_ms": 1.04,
"mean_ms": 0.95
}
},
{
"asset": "anyr-windows-x86_64.exe",
"kind": "native",
"path": "D:\\a\\cli\\cli\\anyr-windows-x86_64.exe",
"bytes": 2576384,
"size": "2.5 MiB",
"version": "0.1.11 (built 2026-08-28T04:30:28Z)",
"target": "x86_64-pc-windows-msvc",
"os": "windows-latest",
"startup_version": {
"n": 21,
"min_ms": 8.54,
"median_ms": 8.72,
"p95_ms": 9.25,
"mean_ms": 8.77
},
"startup_help": {
"n": 21,
"min_ms": 8.62,
"median_ms": 8.79,
"p95_ms": 10.94,
"mean_ms": 9.18
}
},
{
"asset": "anyr.wasm",
"kind": "wasm",
"path": "/home/runner/work/cli/cli/target/wasm-pkg/anyr_cli_bg.wasm",
"bytes": 179312,
"size": "175.1 KiB",
"version": "wasm",
"target": "wasm32-unknown-unknown",
"os": ""
}
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The relay named worker threads by byte-slicing the first 8 bytes of a cloud-controlled request id. A multibyte UTF-8 character in those bytes panics (
byte index N is not a char boundary). Release ispanic = "abort", so one bad frame killed the whole relay.This truncates the id by Unicode scalar values (
chars().take(8)) for the thread name only. The in-flight map still keys on the full id.Closes #17 (Plan 002).
Checklist
Skip co-authors
Plan verification
git diff --stat 61ee3c7..HEAD -- src/relay.rswas empty before the change; livespawn_requestmatched the issue excerpt.src/relay.rschanged.grep -n 'frame.id\[' src/relay.rs→ no matches.grep -n 'chars().take' src/relay.rs→ helper at theshort_iddefinition.cargo build --locked→ exit 0 (local sandbox rustc 1.98.0, matching CI@stable).cargo test --locked --lib relay→ 15 passed, includingshort_id_is_char_boundary_safe_and_bounded.cargo clippy --locked --all-targets→ 13 pre-existing lib warnings; none new inrelay.rs.Out of scope (reported, not fixed)
No other untrusted-string (
&str[..n]) slices remain inrelay.rs. The other..slices are on raw byte buffers (buf/pending) afterutf8_flush_len, plus unit-test fixtures.